<?php
@session_start();
define('PNT', true);
include("../includes/config.php");
include("../includes/functions.php");
include("admin_functions.php");
include("../control/PgSQL.php");

if (isset($_GET['do']) && $_GET['do'] == 'logout') {
    session_unregister('login');
    session_unregister('level');
    session_unregister('user_id');
    session_unregister('username');
}

if (!isset($_SESSION['login']) || !isset($_SESSION['level']) || $_SESSION['login'] != 1 || $_SESSION['level'] != 2) {
    
    header("Location: login.php");
}
?>

<!DOCTYPE HTML>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="author" content="PNT" />

	<title>Administrator : <?php echo $config['web_title'] ?></title>
    <link rel="stylesheet" href="../css/admin.css" />
    <script type="text/javascript" charset="utf-8" src="../js/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/jquery-ui-1.7.2.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/jquery.validate.min.js"></script>
    <script type="text/javascript">    
    	tinyMCE.init({
    		mode : "textareas",
    		theme : "advanced",
    		plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave"
            
    	});
    </script>

</head>

<body>

<div id="wrapper">
    
    <div id="header">
        Chào: <?php echo $_SESSION['username'] ?>    <a href="index.php?do=logout">Thoát</a>
    </div>
    
    <div id="dashboard">
        <ul>
            <li><a href="index.php">Trang chủ</a></li>
            <li><a href="index.php?mod=news&act=list">Bài viết</a></li>
			<li><a href="index.php?mod=contact&act=list">Liên hệ</a></li>
            <li><a href="index.php?mod=user&act=list">Thành viên</a></li>
			<li><a href="index.php?mod=hotel&act=list">Khách sạn</a></li>
			<li><a href="index.php?mod=cmt&act=list">Nhận xét</a></li>
        </ul>
    </div>
    
    <div id="main">
        <?php 
            if (isset($_GET['mod'])) {
                $mod = $_GET['mod'];
                switch ($mod)
                {
                    case "news": include("admin_news.php"); break;
					case "contact": include("admin_contact.php"); break;
                    case "user": include("admin_user.php"); break;
					case "hotel": include("admin_hotel.php"); break;
					case "cmt": include("admin_hotel_cmt.php"); break;
                    default: include ("home.php"); break;
                }
            } else {
                    include ("home.php");
            } 
        ?>
    </div>
    
    
</div>



</body>
</html>